#ifndef TRAFFICWID_H
#define TRAFFICWID_H

#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
#include <vector>
#include <QLabel>
#include <QMouseEvent>
#include "controller.h"

using namespace std;
namespace Ui {
class TrafficWid;
}

class QDESIGNER_WIDGET_EXPORT TrafficWid : public QWidget
{
    Q_OBJECT

public:
    explicit TrafficWid(QWidget *parent = 0);
    ~TrafficWid();
    //新建label
    void new_label();
    //设置label色块的颜色，长度
    void set_value(int index, QString color, QString text, int value, bool display);
    //设置label色块的数量
    void set_count(int count)
    {
        Count = count;
    }

    int get_count()
    {
        return Count;
    }

    void set_cont(Controller cont)
    {
        Cont = cont;
    }

    Controller get_cont()
    {
        return Cont;
    }

protected:
    //重写mousePressEvent事件
    virtual void mousePressEvent(QMouseEvent* event);
signals:
    void clicked(Controller);
private:
    Ui::TrafficWid *ui;

    int Count;

    vector<QLabel*> labelvec;

    Controller Cont;
};

#endif // TRAFFICWID_H
